home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / devparam.c < prev    next >
C/C++ Source or Header  |  1994-06-04  |  1KB  |  75 lines

  1. #include <string.h>
  2. #include <ctype.h>
  3. #include "global.h"
  4. #include "devparam.h"
  5.  
  6. struct param {
  7.     int number;
  8.     char *name;
  9. };
  10. static struct param Parms[] = {
  11.     PARAM_DATA,    "Data",
  12.     PARAM_TXDELAY,    "TxDelay",
  13.     PARAM_PERSIST,    "Persist",
  14.     PARAM_SLOTTIME,    "SlotTime",
  15.     PARAM_TXTAIL,    "TxTail",
  16.     PARAM_FULLDUP,    "FullDup",
  17.     PARAM_HW,    "Hardware",
  18.     PARAM_MUTE,    "TxMute",
  19.     PARAM_DTR,    "DTR",
  20.     PARAM_RTS,    "RTS",
  21.     PARAM_SPEED,    "Speed",
  22.     PARAM_ENDDELAY,    "EndDelay",
  23.     PARAM_GROUP,    "Group",
  24.     PARAM_IDLE,    "Idle",
  25.     PARAM_MIN,    "Min",
  26.     PARAM_MAXKEY,    "MaxKey",
  27.     PARAM_WAIT,    "Wait",
  28.     PARAM_DOWN,    "Down",
  29.     PARAM_UP,    "Up",
  30.     PARAM_BLIND,    "Blind",
  31.     PARAM_RETURN,   "Return",
  32.     PARAM_RETURN2,  "Return2",
  33.     -1,        NULLCHAR,
  34. };
  35.     
  36. /* Convert a packet radio interface control token into a number
  37.  * Used by the various ioctl routines and by KISS TNC commands
  38.  */
  39. int
  40. devparam(s)
  41. char *s;
  42. {
  43.     int len;
  44.     struct param *sp;
  45.  
  46.     len = strlen(s);
  47.     if(isdigit(s[0]))
  48.         return atoi(s);
  49.  
  50.     sp = &Parms[0];
  51.     while(sp->number != -1){
  52.         if(strnicmp(s,sp->name,(size_t)len) == 0)
  53.             return sp->number;
  54.         sp++;
  55.     }        
  56.     return -1;
  57. }
  58.  
  59. char *
  60. parmname(n)
  61. int n;
  62. {
  63.     struct param *sp;
  64.  
  65.     sp = &Parms[0];
  66.     while(sp->number != -1){
  67.         if(sp->number == n)
  68.             return sp->name;
  69.         sp++;
  70.     }        
  71.     return NULLCHAR;
  72. }
  73.  
  74.  
  75.